<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      >
    <h:head>
        <title>Download Template</title>
        <script>
            function confirmComplete() {
                var answer = confirm("Bạn có chắc chắn muốn xóa bản ghi này?");
                if (answer == true)
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
        </script>        
    </h:head>
    <h:body> 
        <link type="text/css" rel="stylesheet" href="../css/main.css" />        
        <style type="text/css">
            .ui-widget{font-size:95% !important;}
            .ui-layout-unit-content{background-color: #E5E5E5;border-width: 0px}      
            .ui-widget{border-width: 0px;color: red}
        </style>
        <div align="center" id="bodyForm" >            
            <div style="width: 100%;">
                <p:layoutUnit id="top" position="north" size="auto">
                    <ui:insert name="menu">
                        <ui:include src="../../templates/menu.xhtml"/>
                    </ui:insert>
                </p:layoutUnit>

                <p:layoutUnit id="center" position="center" size="400">
                    <h1 class="headerbar">Download Template</h1>
                    <h:form id="form">
                        <br></br>
                        <p:growl id="messages"/> 
                        <p:dataTable value="#{downloadTemplateController.items}" var="ct" style="width: 300px"
                                     paginator="true" rows="20" paginatorPosition="bottom">
                            <p:column headerText="Template">
                                <div align="center">
                                    <h:outputText value="#{ct.name}"/>
                                </div>
                            </p:column>
                            <p:column headerText="Download">
                                <div align="center">
                                    <p:commandButton id="downloadLink" ajax="true" onclick="PrimeFaces.monitorDownload(start, stop)"   
                                                     icon="ui-icon ui-icon-arrowthick-1-s" update=":form" rendered="#{downloadTemplateController.check()}">  
                                        <p:fileDownload value="#{downloadTemplateController.file}"/>  
                                    </p:commandButton> 
                                    <h:outputText value="Chưa cập nhật file" style="color: red" rendered="#{not downloadTemplateController.check()}"/>
                                </div>
                            </p:column>
                        </p:dataTable>
                        <br/>
                    </h:form>
                </p:layoutUnit>
                <p:layoutUnit id="bottom" position="bottom" size="60">
                    <ui:insert name="footer">
                        <ui:include src="../../templates/footer.xhtml"/>
                    </ui:insert>
                </p:layoutUnit>
            </div>
        </div>
    </h:body>
</html>

